﻿using System.Collections;
using System.Collections.Generic;
using App.Common;
using UnityEngine;
using Chronos;


public class Move : SkillBase
{
    //public CharaBase Player;
    public RigidbodyTimeline2D rb;    
    public float moveSpeedRatio = 1;
    public Vector2 moveInput;

    public override void Init(EntityBase user)
    {
        base.Init(user);
        rb = User.time.rigidbody2D;
        //Debug.Log("init move");
    }
    public override void FixedUpdate()
    {
        moveInput = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")).normalized;
        if(moveInput.magnitude != 0)
        {
            rb.velocity = moveInput
                        * User.parameter.MovementData.moveSpeed
                        * moveSpeedRatio;
            User.parameter.MovementData.moveDir = rb.velocity.normalized;
            User.ChangeState(States.MoveState);
        }
        else
        {
            User.ChangeState(States.StandState);
            rb.velocity = Vector2.zero;
        }
        
    }
}
